import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

/**
 * 为了能够区分哪些路由需要被拦截，我们在路由里添上一个元数据requireAuth来做是否需要拦截的判断：
 */
const routes = [

  {
    path: '/',
    component: () => import('../views/Login.vue')
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue')
  },
  {
    path: '/main',
    name: 'MainList',
    component: () => import('../views/MainList.vue'),
    meta: {
      requireAuth: true
    }
  },
  {
    path: '/user',
    name: 'UserList',
    component: () => import('../views/UserList.vue'),
    meta: {
      requireAuth: true
    }
  },
  {
    path: '/compared',
    name: 'ComparedList',
    component: () => import('../views/ComparedList.vue'),
    meta: {
      requireAuth: true
    }
  },
  {
    path: '/history',
    name: 'HistoryList',
    component: () => import('../views/HistoryList.vue'),
    meta: {
      requireAuth: true
    }
  }
]

const router = new VueRouter({
  routes
})

export default router
